﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Pg.BioMedics.SDR.Data.Configuration
{
    /// <summary>
    /// Data access configuration section
    /// </summary>
    public class DataAccessConfigurationSection : ConfigurationSection
    {
        #region Constants

        public const string SectionName = "dataAccessSettings";
        private const string SettingsProperty = "settings";

        #endregion

        #region Properties

        /// <summary>
        /// Settings collection
        /// </summary>
        [ConfigurationProperty(SettingsProperty)]
        public SettingsElement Settings
        {
            get
            {
                return this[SettingsProperty] as SettingsElement;
            }

            set
            {
                this[SettingsProperty] = value;
            }
        }

        #endregion

        #region Static methods

        /// <summary>
        /// Gets configuration from current configuration file
        /// </summary>
        /// <returns></returns>
        public static DataAccessConfigurationSection GetConfiguration()
        {
            return ConfigurationManager.GetSection(SectionName) as DataAccessConfigurationSection ?? new DataAccessConfigurationSection();
        }

        #endregion
    }
}
